package com.pencilisland.pay.mgt.console.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pencilisland.pay.mgt.console.bean.JstreeNode;
import com.pencilisland.pay.mgt.console.service.JspFunctions;
import com.pencilisland.pay.mgt.console.service.OrgService;

@Component("jspFn")
public class JspFunctionsImpl implements JspFunctions {

	Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	OrgService orgService;
	@Autowired
	ObjectMapper objectMapper;

	@Override
	public String organJsTreeJSON() {
		JstreeNode data = orgService.orgTreeData(1L);
		try {
			return objectMapper.writeValueAsString(data);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
			log.error("加载组织机构树数据异常");
		}

		return "";
	}

}
